home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / recode.lha / recode-3.2.4 / ibmpicon.c < prev    next >
C/C++ Source or Header  |  1992-08-19  |  2KB  |  76 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #define STEP    ibmpc_iconqnx
  21. #include <stdio.h>
  22. #include "common.h"
  23.  
  24. #define DOS_EOF    0x1A        /* MS-DOS old end-of-file */
  25. #define ESCAPE    0x19        /* Escape for diacritic application */
  26. #define ENDLINE    0x1E        /* End-line code for QNX */
  27.  
  28. #define TRANSLATE_AND_BREAK(c2, c3) \
  29.   putc (ESCAPE, output_file); \
  30.   putc (c2, output_file); \
  31.   putc (c3, output_file); \
  32.   input_char = getc (input_file); \
  33.   break;
  34.  
  35. void
  36. STEP (FILE *input_file, FILE *output_file)
  37. {
  38.   int input_char;
  39.  
  40.   input_char = getc (input_file);
  41.   while (input_char != EOF && input_char != DOS_EOF)
  42.     switch (input_char)
  43.       {
  44.       case 0x85: TRANSLATE_AND_BREAK ('A', 'a');
  45.       case 0x8A: TRANSLATE_AND_BREAK ('A', 'e');
  46.       case 0x97: TRANSLATE_AND_BREAK ('A', 'u');
  47.       case 0x82: TRANSLATE_AND_BREAK ('B', 'e');
  48.       case 0x90: TRANSLATE_AND_BREAK ('B', 'E');
  49.       case 0x83: TRANSLATE_AND_BREAK ('C', 'a');
  50.       case 0x88: TRANSLATE_AND_BREAK ('C', 'e');
  51.       case 0x8C: TRANSLATE_AND_BREAK ('C', 'i');
  52.       case 0x93: TRANSLATE_AND_BREAK ('C', 'o');
  53.       case 0x96: TRANSLATE_AND_BREAK ('C', 'u');
  54.       case 0x89: TRANSLATE_AND_BREAK ('H', 'e');
  55.       case 0x8B: TRANSLATE_AND_BREAK ('H', 'i');
  56.       case 0x81: TRANSLATE_AND_BREAK ('H', 'u');
  57.       case 0x87: TRANSLATE_AND_BREAK ('K', 'c');
  58.       case 0x80: TRANSLATE_AND_BREAK ('K', 'C');
  59.  
  60.       case 0x0D:
  61.     input_char = getc (input_file);
  62.     if (input_char == 0x0A)
  63.       {
  64.         putc (ENDLINE, output_file);
  65.         input_char = getc (input_file);
  66.       }
  67.     else
  68.       putc (0x0D, output_file);
  69.     break;
  70.  
  71.       default:
  72.     putc (input_char, output_file);
  73.     input_char = getc (input_file);
  74.       }
  75. }
  76.